import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:share_fit/app/models/home/date_type_enum.dart';
import 'package:share_fit/app/models/home/stress_model.dart';
import 'package:share_fit/app/tools/date_tool.dart';

class PressureRatio {
  double percent;
  String indicatorText;
  Color valueColor;

  PressureRatio(this.percent, this.indicatorText, this.valueColor);

  get percentText => percent <= 0.0 ? '--%' : '${(percent * 100).truncate()}%';
}

class StressState {
  Rx<DateType> selectedDateType = DateType.day.obs;

  /// 最新的压力值
  String currentPressureText = '--';

  /// 压力图表数据
  List<StressModel> modelList = [];

  /// 压力占比
  List<PressureRatio> ratioList = [];

  /// 右上角日历选择的日期
  DateTime selectedDate = DateTime.now();

  /// 保存有压力记录的日期列表
  Map<DateTime, List<bool>> dateListOfRecord = {};

  /// 保存平均值、最大值、最小值
  Map dataDetail = {'avg_pressure_value': '--', 'max_pressure_value': '--', 'min_pressure_value': '--'};

  String dateRangeText = DateTool.getYMDWithDash(DateTime.now()).replaceAll('-', '/');

  int dateTypeBarIndex = 0;

  StressState() {
    ///Initialize variables
  }
}
